<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			input{
				width: 60px;
			}
		</style>
	</head>
	<body>
		<div id="div1">
			<input type="text" value="" id="top1"/>
			<input type="button" value="+">
			<input type="text" value="" id="top2">
			<input type="button" value="=" id="dd">
			<input type="text" value="" id="top3"/>
		</div>
		<div>
			<input type="text" value="" id="number1"/>
			<input type="button" value="+" >
			<input type="text" value="" id="number2">
			<input type="button" value="=">
			<input type="text" value="" id="number3">
		</div>
		<input type="button" value="点击" id="btn" />
	</body>
	<script>
		btn.onclick = function(){
			if(top1.value == '' || top2.value== '' || top3.value== '' 
			|| number1.value== '' || number2.value== '' || number3.value == ''){
				alert('不能有空')
			}else{
				if(Number(top1.value) + Number(top2.value) == Number(top3.value) && Number(number1.value) + Number(number2.value) == Number(number3.value)){
					alert('答案是正确的')
				}else{
					alert('有一个是错误的')
				}
			}
		}
		dd.onclick = function(){
			if(top1.value == '' || top2.value== '' ){
				alert('输入框不能为空');
				return 0;
			}else{
				var top3 = Number(top1.value) + Number(top2.value);
				var element = document.getElementById('top3');
				element.value = top3.toString();
			}
			
			
		}
	</script>
</html>